package com.hzncc.flowable_diboot.flowable.event.refund;

import com.diboot.core.util.ContextHolder;
import com.hzncc.flowable_diboot.constans.ContractModelKeyConstants;
import com.hzncc.flowable_diboot.flowable.event.BpmProcessInstanceStatusEvent;
import com.hzncc.flowable_diboot.flowable.event.BpmProcessInstanceStatusEventListener;
import com.hzncc.flowable_diboot.service.refundmanage.RefundContractService;
import com.hzncc.flowable_diboot.service.refundmanage.impl.RefundContractServiceImpl;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;

@Component
public class RefundContractStatusListener extends BpmProcessInstanceStatusEventListener {

    @Override
    protected String getProcessDefinitionKey() {
        return ContractModelKeyConstants.REFUND_CONTRACT_SUBMIT;
    }

    @Override
    protected void onEvent(BpmProcessInstanceStatusEvent event) {
        RefundContractService refundContractService = ContextHolder.getBean(RefundContractServiceImpl.class);
        refundContractService.updateRefundContractStatus(event.getBusinessKey(), String.valueOf(event.getStatus()));
    }
}
